<script setup>
import { ref, onMounted } from "vue";
import { useRoute } from "vue-router";
import { getLiveOrderDetailAPI } from "@/server/api/shopOrder";
import { useUseStore } from "@/stores/user";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
/*
 *&注册区
 */
const route = useRoute();
const useStore = useUseStore();
/*
 *&变量申明区
 */
const HotelDetail = ref({}); //列表数据
const page = ref(1); //定义列表页数
const data = ref({});

/*
 *&函数申明区
 */

//定义获取列表函数
const getLiveOrderDetail = async (shopId) => {
  const res = await getLiveOrderDetailAPI(shopId);
  HotelDetail.value = res.data.data;
  HotelDetail.value.orderId = shopId;
  console.log(res);
};


onMounted(() => {
  console.log(JSON.parse(route.query.data));
  data.value = JSON.parse(route.query.data);
  getLiveOrderDetail(data.value.orderId);
});
</script>




<template>
  <div class="HotelChecked">
    <van-sticky>
      <top-button-live-detail :title="'shop'" />
    </van-sticky>

    <ul class="counter">
      <li>
        <div class="title">{{ data.shopName }}</div>
        <div class="count">
          <div class="picture">
            <img :src="data.userImage" alt="" />

          </div>
          <div class="right">
            <h4>{{ data.shopIntroduce?.substring(0, 20) }}</h4>
            <p class="int">
              {{ $t("me.addNewAddress.phone") }}:
              {{ HotelDetail.phone }}
            </p>
            <p class="timer">{{ data.address }}</p>
          </div>
        </div>
      </li>
      <li>
        <div class="title">{{ data.roomTypeName }}</div>
        <div class="count">
          <div class="picture">
            <!-- <img
              :src="data.imageList[index]"
              alt=""
              v-for="(i, index) in data.imageList"
              :key="index"
            /> -->
            <img :src="data.avatarImag" alt="" />
          </div>
          <div class="right">
            <h4>{{ HotelDetail.detail?.substring(0, 20) }}</h4>
            <p class="int">
              {{
                HotelDetail.room +
                $t("hotelChekced.room") +
                HotelDetail.bed +
                $t("hotelChekced.bed") +
                HotelDetail.restRoom +
                $t("hotelChekced.bathroom") + "/" +
                HotelDetail.number +
                $t("pay.orderCount")
              }}
            </p>
            <p class="timer">{{ HotelDetail.land }} m²</p>
          </div>
        </div>
      </li>
    </ul>
    <div class="box">
      <div class="title">{{ $t("hotelChekced.pay") }}</div>
      <div class="item">
        <div class="left">
          {{ $t("hotelChekced.order") }}
        </div>
        <div class="right">{{ HotelDetail.orderId }}</div>
      </div>
      <div class="item">
        <div class="left">{{ $t("pay.orderTime") }}：</div>
        <div class="right">{{ HotelDetail.createTime }}</div>
      </div>
      <div class="item">
        <div class="left">{{ $t("pay.payTime") }}：</div>
        <div class="right">{{ HotelDetail.payTime }}</div>
      </div>
      <div class="item">
        <div class="left">{{ $t("hotelChekced.price") }}：</div>
        <div class="right">{{ data.transactionAmount }}</div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
/* 房间图片展示部分 */
.HotelChecked .counter {
  padding: 50rem 0rem 10rem 0;
}

/* 设置整体页面样式 */
.HotelChecked {
  font-family: 'Arial', sans-serif;
  background-color: #f7f7f7;
  padding: 30px;
  max-width: 1100px;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Sticky bar 样式 */
.van-sticky {
  background-color: #fff;
  z-index: 999;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  padding: 12px 20px;
  margin-bottom: 20px;
}

/* 顶部按钮 */
.top-button {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

/* 酒店信息列表 */
.counter {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.counter li {
  margin-bottom: 30px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  padding: 25px;
  display: flex;
  flex-direction: column;
}

.counter .title {
  font-size: 22px;
  font-weight: bold;
  color: #333;
}

.counter .count {
  display: flex;
  align-items: center;
}

.counter .picture {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  border-radius: 8px;
  margin-right: 20px;
}

.counter .picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.counter .right {
  flex: 1;
}

.counter .right h4 {
  font-size: 20px;
  color: #333;
  font-weight: bold;
  margin: 0 0 8px 0;
}

.counter .right .int,
.counter .right .timer {
  font-size: 16px;
  color: #666;
  margin: 5px 0;
}

.counter .right h4 {
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 订单支付信息样式 */
.box {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.box .title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 25px;
}

.box .item {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #f1f1f1;
}

.box .item:last-child {
  border-bottom: none;
}

.box .left {
  font-size: 18px;
  color: #888;
}

.box .right {
  font-size: 18px;
  color: #333;
  font-weight: bold;
}

/* 高亮的支付金额 */
.box .item .right {
  color: #e74c3c;
}

/* 响应式处理 */
@media screen and (max-width: 768px) {
  .HotelChecked {
    padding: 20px;
  }

  .counter li {
    flex-direction: column;
    align-items: flex-start;
  }

  .counter .count {
    flex-direction: column;
    align-items: flex-start;
  }

  .counter .picture {
    width: 80px;
    height: 80px;
  }

  .counter .picture img {
    width: 100%;
    height: 100%;
  }

  .box {
    padding: 20px;
  }

  .box .item {
    padding: 10px 0;
  }
}
</style>
